package com.da.javatest.leetCode2;

public class Code26 {
    public static void main(String[] args) {
        System.out.println(new Code26().removeDuplicates(new int[]{0,0,1,1,1,2,2,3,3,4}));
    }

    public int removeDuplicates(int[] nums) {
        int index = nums.length - 1;
        for (int i = 0; i < index; i++) {
            if (nums[i] == nums[i + 1]) {
                for (int j = i + 1; j < index; j++) {
                    nums[j] = nums[j + 1];
                }
                i--;
                index--;
            }
        }
        return index + 1;
    }
}
